'use strict';
let Response = require('../../../model/Response');
let RestifyProxy = require('../../../util/RestifyProxy');
let CustomPageBean = require('../../../model/CustomPageBean');
let lightmethodService = require('../../../service/operate/lightmethodService.js');
let logger = require('../../../util/LoggerUtil').logger('lightmethodController.js');

/**
 * 照明策略——页面
 */
module.exports.lightmethodPage = function () {
    let response = new Response();
    response.render('back/operate/lightmethod/lightmethod');//html路径
    this.resolve(response);
};


/**
 * 照明策略——列表
 */
module.exports.lightmethodList = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await lightmethodService.getlightmethod(this, params);
        let pageBean = new CustomPageBean(result);
        response.send(pageBean);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};


/*========================================================================*/
/**
 * 照明策略-创建照明策略-页面
 */module.exports.lightmethod_create = function () {
    let response = new Response();
    response.render('back/operate/lightmethod/lightmethod_create');
    this.resolve(response);
};


/**
 * 照明策略-创建照明策略-保存按钮
 */
module.exports.lightmethodCreateSave = async function () {
    let req = this.req;
    let user = req.user;
    let params = req.body;

    let response = new Response();
    try {
        let result = await lightmethodService.lightmethodCreateSave(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};

/**
 * 照明策略-详情
 */
module.exports.lightmethodDetailPage = function () {
    let response = new Response();
    // response.render('back/operate/lightmethod/lightmethod_detail', {account: {phone: 15320897908, realName: '雨夜'}});
    response.render('back/operate/lightmethod/lightmethod_detail');
    this.resolve(response);
};

/**
 * 通过策略id，获取照明策略-详情
 */
module.exports.lightmethodDetailData = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await lightmethodService.lightmethodDetailData(this, params);
        console.log("stttttt"+params);
        console.log(params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};


/**
 * 照明策略-修改-页面
 */
module.exports.lightmethodModifyPage = function () {
    let response = new Response();
    response.render('back/operate/lightmethod/lightmethod_modify');
    this.resolve(response);
};

/**
 * 通过策略id，修改照明策略信息
 */
module.exports.lightmethodModifySave = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await lightmethodService.lightmethodModifySave(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/* *
* 照明策略-删除按钮
*/
module.exports.lightmethodDelete = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await lightmethodService.lightmethodDelete(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};

/**
 * 通过用户ID，删除用户
 */
/*module.exports.deleteUserByUserId = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await userInfoService.deleteUserByUserId(this, params.userId);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};*/


/**
 * 启动账户
 */
/*module.exports.enabledUserByUserId = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await userInfoService.enabledUserByUserId(this, params.userId);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};*/


/**
 * 禁用账户
 */
/*module.exports.disabledUserByUserId = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await userInfoService.disabledUserByUserId(this, params.userId);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};*/
